'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async index() {
    const { ctx, app, service } = this;
    try {
      const jsonBody = ctx.request.body;
      const { size, count } = jsonBody.data.page;
      const con = await service.home.index(size, count)
      ctx.body = con;
    } catch (err) {
      const con = await service.home.index(1, 2)
      ctx.body = con;
    }
  }
  async details() {
    const { ctx, app, service } = this;
    try {
      const id = ctx.params.id
      const con = await service.home.details(id)
      ctx.body = con;
    } catch (err) {
      ctx.body = '传参错误' + err;
    }
  }
}

module.exports = HomeController;
